package com.ljx.recruitment.security.config;

import com.ljx.recruitment.security.interceptor.AccessTokenInterceptor;
import com.ljx.recruitment.security.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-10-01  19:16
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Autowired
    private AccessTokenInterceptor accessTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .order(2);
        registry.addInterceptor(accessTokenInterceptor)
                .addPathPatterns("/**")
                .order(1);
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
